package cn.javaSong.controller;


import cn.javaSong.common.ResponseHelper;
import cn.javaSong.common.ResponseModel;
import cn.javaSong.entity.Huya;
import cn.javaSong.mapper.HuyaMapper;
import cn.javaSong.service.IHuyaService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author dakai
 * @since 2024-11-06
 */
@RestController
@Api(tags = "多图链接模块")
@RequestMapping("/huya")
public class HuyaController {

    @Resource
    private IHuyaService iHuyaService;

    @Resource
    private HuyaMapper huyaMapper;
    /**
     * 新增
     * @param huya
     * @return
     */
    @ApiOperation(value = "新增")
    @PostMapping("/save")
    public ResponseModel addImg(@RequestBody List<Huya> huya) {
        return iHuyaService.addHuyaImg(huya);
    }

    @ApiOperation("查询")
    @GetMapping("/select")
    public ResponseModel select() {
        List<Huya> huyas = huyaMapper.select();
        return ResponseHelper.buildResponseModel(huyas);
    }

    @ApiOperation("分页查询")
    @PostMapping("/selectHuya")
    public ResponseModel<IPage<Huya>> selectKai(Integer pageNo, Integer pageSize) {
        IPage<Huya> p = new Page<>(pageNo, pageSize);
        return ResponseHelper.buildResponseModel(huyaMapper.selectHuya(p));
    }
}
